package com.ruoyi.code.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import com.gyf.immersionbar.ktx.immersionBar
import com.ruoyi.app.R
import com.ruoyi.code.base.viewbinding.base.ActivityBinding
import com.ruoyi.code.base.viewbinding.base.ActivityBindingDelegate
import com.ruoyi.code.utils.ActivityManager
import com.therouter.TheRouter

abstract class BaseBindingActivity<VB : ViewBinding> : AppCompatActivity(),
    ActivityBinding<VB> by ActivityBindingDelegate() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentViewWithBinding()
        immersionBar {
            fitsSystemWindows(true)
            statusBarDarkFont(true)
            statusBarColor(R.color.white)
            navigationBarColor(R.color.white)
        }

        TheRouter.inject(this)

        ActivityManager.instance.addActivity(this)

        initView()
        initData()

    }

    abstract fun initView()

    abstract fun initData()

    override fun onDestroy() {
        super.onDestroy()
        ActivityManager.instance.removeActivity(this)
    }
}